package com.example.demo.domain.base;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * PageParam
 *
 * @author hao.chen
 * @date 2022/12/28 17:02
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class PageParam extends BaseParam {
    /** 默认的页号 */
    private static final int DEFAULT_PAGE_NUM = 1;
    /** 默认的每页条数 */
    private static final int DEFAULT_PAGE_SIZE = 10;

    /** 分页大小 */
    private int pageSize = DEFAULT_PAGE_SIZE;
    /** 分页页码 */
    private int pageNum = DEFAULT_PAGE_NUM;

    public int getPageSize() {
        return (this.pageSize < 0 || this.pageSize > 200) ? DEFAULT_PAGE_SIZE : this.pageSize;
    }

    public int getPageNum() {
        return this.pageNum < 0 ? DEFAULT_PAGE_NUM : this.pageNum;
    }
}
